using System;
using System.Transactions;
using EstimateTracker.Domain.Entities;
using JetBrains.Annotations;

namespace EstimateTracker.DataAccess.Repositories
{
    public class HoursWorkedRepository : IHoursWorkedRepository
    {
        private readonly IPersistenceManager _persistManager;

        public HoursWorkedRepository([NotNull] IPersistenceManager persistManager)
        {
            if (persistManager == null) throw new ArgumentNullException("persistManager");
            _persistManager = persistManager;
        }

        public void Save(HoursWorked hoursWorked)
        {
            using (var scope = new TransactionScope())
            {
                _persistManager.Persist(hoursWorked);
                scope.Complete();
            }
        }
    }
}